package com.ptszyxx.popose.module.main.game.adapter;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.viewholder.BaseDataBindingHolder;
import com.ptszyxx.popose.R;
import com.ptszyxx.popose.common.utils.YActivityUtil;
import com.ptszyxx.popose.databinding.ItemGameBinding;
import com.ptszyxx.popose.module.main.game.vm.GameVM;
import com.ysg.http.data.entity.game.GameEntity;
import com.ysg.utils.YImageUtil;

public class GameAdapter extends BaseQuickAdapter<GameEntity, BaseDataBindingHolder<ItemGameBinding>> {

    private GameVM viewModel;
    private Presenter presenter = new Presenter();
    public GameAdapter(GameVM viewModel) {
        super(R.layout.item_game);
        this.viewModel = viewModel;
    }

    @Override
    protected void convert(BaseDataBindingHolder<ItemGameBinding> holder, GameEntity item) {
        ItemGameBinding binding = holder.getDataBinding();
        if (binding != null) {
            binding.setEntity(item);
            binding.setViewModel(viewModel);
            binding.setPresenter(presenter);
            binding.executePendingBindings();

            YImageUtil.show(binding.ivAvatar, item.getPic());
        }
    }

    public static class Presenter{
        public void onItemClick(GameVM viewModel, GameEntity entity){
            YActivityUtil.getInstance().jumpGameDetail(viewModel, entity);
        }
    }





}
